package com.ruoyi.yl.controller;


import com.ruoyi.yl.common.Result;
import com.ruoyi.yl.domain.YlDrug;
import com.ruoyi.yl.domain.YlStockManageInfo;
import com.ruoyi.yl.service.StockControlService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import static com.ruoyi.yl.constant.YlConstant.*;
import javax.annotation.Resource;
import java.util.List;

/**
 * @Author: linKe
 * @Date: 2022/2/17 17:24
 * @FileName: StockArrangeManageController
 * @version: 1.0
 * @Description: 库存管理
 */
@RestController
@RequestMapping("/stockControl")
public class StockControlController {
    @Resource
    private StockControlService stockControlServiceImpl;
    /**
     * 查询仓库中所有药品信息
     */
    @GetMapping("/getAllDrug")
    public Result<List<YlDrug>> getAllDrug(){
        List<YlDrug> allDrug = stockControlServiceImpl.getAllDrug();
        return new Result<>(OP_SUCCESS_CODE,OP_SUCCESS_MSG,allDrug);
    }
    /**
     * 根据药品的处方类型查药品
     */
    @GetMapping("/getDrugsByType/{id}")
    public Result<List<YlDrug>> getDrugsByType(@PathVariable("id")Long id){
        /// Integer value = prescriptionType.getValue();
        List<YlDrug> drugsByType = stockControlServiceImpl.getDrugsByType(id);
        return  new Result<>(OP_SUCCESS_CODE,OP_SUCCESS_MSG,drugsByType);
    }
    /**
     * 根据药品名称、编码、生产厂家进行模糊查询
     */
    @GetMapping("/getDrugsByLikes")
    public Result<List<YlDrug>> getDrugsByLikes(String dsc){
        List<YlDrug> drugsByLikes = stockControlServiceImpl.getDrugsByLikes(dsc);
        return new Result<>(OP_SUCCESS_CODE,OP_SUCCESS_MSG,drugsByLikes);
    }
    /**
     * 根据药品id查询出入库和药品信息
     */
    @GetMapping("/getInfoById/{id}")
    public Result<YlStockManageInfo> getInfoById(@PathVariable("id")Long id){
        YlStockManageInfo infoById = stockControlServiceImpl.getInfoById(id);
        return new Result<>(OP_SUCCESS_CODE,OP_SUCCESS_MSG,infoById);
    }
}
